<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>{{ title }}</title>
</head>
<style>
    *{
        margin: 0;
        padding: 0;
        background-color: #eeeeee;
    }
    body{
        width: 100%;
        height: 100%;
        /*background-color: lightgray;*/
    }
    .content {
        margin-top: 20px;
        margin-left:5%;
        width: 90%;
        background-color: #f8f8f8;
    }
    .content .title{
        text-align: center;
        margin-bottom: 20px;

    }
    .tixian{
        background-color: white;
    }
    .tixian form{
        width: 100%;
        background-color: white;
    }
    table{
        width: 90%;
        margin-left: 10%;
        background-color: white;
    }
    table tr td {
        background-color: white;
    }
    table .alert {
        margin-top: 20px;
        background-color: white;
    }
    table .amount {
        margin-top: 30px;
        background-color: white;
        font-size: 30px;
        float: left;
    }
    table .earn{
        margin-top: 30px;
        float: left;
        height: 40px;
        background-color: white;
        width: 86%;
        font-size: 30px;
        border: 1px solid white;
    }
    table .earn:focus{
        outline: none;
    }
    .cash{
        text-align: left;
        margin-top: 20px;
        margin-left: 10%;
        background-color: white;
        color: #2e8ded;
    }

    .submit {
        margin:2rem 10%;
        width: 80%;
        height: 3rem;
        background-color: #ED784A;
        border: 1px #ED784A solid;
        font-family: 黑体;
        font-size: 20px;
        color: white;
        border-radius: 5px;
    }
    .submit:focus{
        outline: none;
    }

</style>
<body>
    <div class="content">
        <div class="title">
            <span>零钱余额￥<strong>{{ cash.account_currency }}</strong></span>
        </div>
        <div class="tixian">
            <form action="" method="POST">
                <table>
                    <tr>
                        <td>
                            <div class="alert">提现金额</div>
                        </td>
                    </tr>
                    <tr>
                        <td style="border-bottom: 1px solid lightgray">
                            <div class="amount">￥</div>
                            <input name="amount" class="earn" type="text">
                            <input name="earn" class="earn" type="hidden" value="{{ cash.account_currency }}">
                            <!--<input name="earn" class="earn" type="hidden">-->
                            <div style="clear: both;"></div>
                        </td>
                    </tr>
                </table>
            </form>
            <div id="allCash" class="cash">全部提现</div>
            <div style="background-color: white"><button  id="btn" class="submit" type="button">提现</button></div>
        </div>
    </div>
</body>
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="../../../resource/js/layer/2.4/layer.js"></script>
<script src='http://app.lxh.magcloud.cc/public/static/dest/js/libs/magjs-x.js'></script>
<script>
    var token;
    mag.toLogin(function(rs){
        token = rs.token;
    });
</script>
<script>

    // 部分体现
    $("#btn").click(function (e) {
        var amount = $('input[name=amount]').val();
        var earn = $('input[name=earn]').val();
        if (!amount){
            mag.toast("提现不能小于0");
            return false;
        } else if (amount > earn) {
            mag.toast("提现额度不能大于零钱余额");
            return false;
        } else{
            applyCash(amount);
        }

    });
    // 全部提现
    $("#allCash").click(function (e) {
        var earn = $('input[name=earn]').val();
        if (!earn){
            mag.toast("提现不能小于0");
            return false;
        } else{
            applyCash(earn);
        }
    });
</script>
<script>
    var applyCash = function (amount) {

        $.ajax({
            type:'POST',
            url: "/Stick/applyCash",
            data:{
                amount:amount,
                token:token,
            },
            dataType:'json',
            success:function (e) {
                mag.toast(e.msg);
                location.reload();
            }
        })
    }
</script>
</html>